/* eslint-disable valid-jsdoc */
import request from "@/router/axios.js";

const scope = "server";
const grant_type = "password";

export const loginByUsername = (username, password, code, randomStr) =>
  request({
    url: "/auth/oauth/token?portalLoading",
    headers: {
      isToken: false,
      // "TENANT-ID": "1",
      Authorization: "Basic Z2RwcjpnZHBy"
    },
    method: "post",
    params: { username, password, randomStr, code, grant_type, scope }
  });

/**
 *
 * @param {Number} query 参数
 * @returns {Function} api
 */
export function getTgUserRole(systemCode, token) {
  return request({
    url: "/admin/menu/rootMenuBySystemCode?portalLoading",
    method: "get",
    params: {
      systemCode
    },
    headers: {
      Authorization: "Bearer " + token
    }
  });
}

/**
 * 判断什么系统
 * @param {Number} query 参数
 * @returns {Function} api
 */
export function getStystemCode(host) {
  return request({
    url: "/admin/sysProduct/getByUrl",
    method: "get",
    params: {
      url: host
    }
  });
}

/**
 * 触发单点url
 * @param {Number} params 参数
 * @returns {Function} api
 */
export function getListFun(params) {
  return request({
    url: "/admin/SysAuthSystem/list",
    method: "get",
    params
  });
}
